home *** CD-ROM | disk | FTP | other *** search
- global guardaQui, pathSeparator, hd, netObj, cd
-
- on checkMimeType riga
- set docname to the pathName & "seealso" & pathSeparator & item 4 of line riga of guardaQui
- set mimeType to item 2 of line riga of guardaQui
- set mimeSubtype to item 3 of line riga of guardaQui
- if the machineType <> 256 then
- if mimeSubtype = "HTML" then
- alert("Purtroppo questa funzione non è ancora implementata su Mac")
- else
- put docname into field 4000
- copyToClipBoard(cast 4000)
- set docname to the text of field 4000
- open(hd & "launch")
- end if
- else
- if mimeSubtype = "HTML" then
- URLClicked(item 4 of line riga of guardaQui)
- else
- set baseFile to cd & pathSeparator & "IMM" & pathSeparator & "mimebase.cfg"
- set configFile to hd & "mime.cfg"
- viewDocument(mimeType, mimeSubtype, docname, configFile, baseFile)
- end if
- end if
- end
-
- on viewDocument mimeType, mimeSubtype, documentName, configFile, baseFile
- set newConfig to 0
- set helperPath to GetConfigHelper(mimeType, mimeSubtype, configFile)
- if helperPath = EMPTY then
- set helperPath to GetBaseHelper(mimeType, mimeSubtype, baseFile)
- if helperPath <> EMPTY then
- if not netObj(mFileExist, helperPath) then
- set helperPath to askHelper(mimeType, mimeSubtype, 1)
- set newConfig to 1
- end if
- else
- set helperPath to askHelper(mimeType, mimeSubtype, 1)
- set newConfig to 1
- end if
- end if
- if (helperPath <> EMPTY) and newConfig then
- AddHelper(mimeType, mimeSubtype, helperPath, configFile)
- end if
- open(documentName, helperPath)
- end
-
- on GetConfigHelper mimeType, mimeSubtype, configFile
- set Obj to FileIO(mnew, "read", configFile)
- if not objectp(Obj) then
- set mimeConfig to EMPTY
- else
- set mimeConfig to Obj(mReadFile)
- Obj(mdispose)
- end if
- set the itemDelimiter to TAB
- set helperPath to EMPTY
- repeat with counter = 1 to the number of lines in mimeConfig
- set testedLine to line counter of mimeConfig
- set testedType to item 1 of testedLine
- set testedSubtype to item 2 of testedLine
- if (testedType = mimeType) and (testedSubtype = mimeSubtype) then
- set helperPath to item 3 of testedLine
- end if
- end repeat
- return helperPath
- end
-
- on GetBaseHelper mimeType, mimeSubtype, baseFile
- set Obj to FileIO(mnew, "read", baseFile)
- if not objectp(Obj) then
- set mimeConfig to EMPTY
- else
- set mimeConfig to Obj(mReadFile)
- Obj(mdispose)
- end if
- set the itemDelimiter to TAB
- set helperPath to EMPTY
- repeat with counter = 1 to the number of lines in mimeConfig
- set testedLine to line counter of mimeConfig
- set testedType to item 1 of testedLine
- set testedSubtype to item 2 of testedLine
- if (testedType = mimeType) and (testedSubtype = mimeSubtype) then
- set helperPath to item 3 of testedLine
- end if
- end repeat
- return helperPath
- end
-
- on askHelper mimeType, mimeSubtype
- set alertString to "Non hai configurato l'applicazione che visualizza i file "
- set alertString to alertString & mimeType & "/" & mimeSubtype
- set alertString to alertString & ". Per favore trova l'applicazione con cui visualizzare questo tipo di file."
- alert(alertString)
- return netObj(mGetPath, "Visualizzatore " & mimeType & "/" & mimeSubtype, "Applicazioni", "*.EXE")
- end
-
- on AddHelper mimeType, mimeSubtype, helperPath, configFile
- set Obj to FileIO(mnew, "read", configFile)
- if not objectp(Obj) then
- set mimeConfig to EMPTY
- else
- set mimeConfig to Obj(mReadFile)
- Obj(mdispose)
- end if
- set Obj to FileIO(mnew, "write", configFile)
- set newContent to mimeConfig & RETURN & mimeType & TAB & mimeSubtype & TAB & helperPath
- Obj(mWriteString, newContent)
- Obj(mdispose)
- end
-
- on esci
- go(1, cd & pathSeparator & "IMM" & pathSeparator & "quit.dir")
- end
-
- on indietro
- end
-